package org.redr.widgetGUI.core;

import org.redr.widgetGUI.settings.WidgetSettings;
import org.redr.widgetGUI.settings.WidgetState;

import com.trolltech.qt.gui.QDialog;
import com.trolltech.qt.gui.QHBoxLayout;
import com.trolltech.qt.gui.QVBoxLayout;
import com.trolltech.qt.gui.QWidget;

public class Dialog extends LayoutState{
	
	private QDialog dialog;
	
	public QDialog widget(){
		return dialog;
	}
	
	public Dialog(WidgetSettings ws){
		super(ws);
		dialog	=	new QDialog();
		dialog.setWindowTitle(_getSetting("label", "!!FIX ME LABEL SHOULD BE SET!!"));
		String ls = _getSetting("layout", "vertical");
		if (ls.equals("horizontal")) dialog.setLayout(new QHBoxLayout());
		else dialog.setLayout(new QVBoxLayout());
	}
	
	@Override
	public void addWidget(WidgetState ws){
		addWidget(ws.getWidgetBox());
	}
	
	@Override
	public void addWidget(QWidget w){
		dialog.layout().addWidget(w);
	}
	
	@Override
	public void show(){
		dialog.show();
	}
	
	@Override
	public void hide(){
		dialog.hide();
	}
	
	public int exec(){
		return dialog.exec();
	}

	@Override
	public void removeWidget(WidgetState ws) {
		// TODO Auto-generated method stub
		removeWidget(ws.getWidgetBox());
	}

	@Override
	public void removeWidget(QWidget w) {
		// TODO Auto-generated method stub
		dialog.layout().removeWidget(w);
	}

}
